const { globalShortcut, screen } = require('electron');
const EnvContext = require('../../common/context/EnvContext');

const { Menu, Tray } = require('electron')
const { app, shell, dialog, Notification } = require('electron');
const fileUtil = require("../../common/utils/fileUtil")



let tray = null
let appBridgeIcon = fileUtil.getResoucePath("/icons/icon@3x.png")

exports.baseTray = function () {
    tray = new Tray(appBridgeIcon)
    const contextMenu = Menu.buildFromTemplate([
        {
            label: "帮助文档",
            click: () => {
                process.nextTick(() => {
                    shell.openExternal("https://gitee.com/appBridge/appBridge-container");
                });
            },
        },
        {
            label: "意见反馈",
            click: () => {
                process.nextTick(() => {
                    shell.openExternal("https://gitee.com/appBridge/appBridge-container/issues");
                });
            },
        },
        { type: "separator" },
        {
            label: "显示窗口",
            accelerator: "Alt+R",
            click() {
                window.show();
            },
        },

        {
            label: "重启",
            click() {
                app.relaunch();
                app.quit();
            },
        },
        { type: "separator" },
        {
            label: "关于",
            click() {
                dialog.showMessageBox({
                    icon: appBridgeIcon,
                    title: "appBridge",
                    message: "基于electron的工具应用容器",
                    detail: `Version: 0.0.1\nAuthor: liuyongliang`,
                });
            },
        },
        {
            role: "quit",
            label: "退出",
        },
    ]);
    tray.setContextMenu(contextMenu)
}